package com.hk.dao.impl;

import com.hk.dao.ICompanyMessageDao;
import com.hk.model.CompanyMessage;
import com.hk.utils.JdbcMysql;
import com.hk.utils.SqlSymbol;

import java.sql.ResultSet;

/**
 * @Author: zhe
 * @Date: 2021/6/22 16:47
 * @Statement: 公司信息Dao层接口实现类
 */
public class CompanyMessageDaoImpl implements ICompanyMessageDao {

    //    JDBC连接工具类
    private static JdbcMysql jdbcMysql = JdbcMysql.getInstance();
    private static String sql = "";

    @Override
    public ResultSet findAll(Integer page, Integer limit) {
        sql = "select * from company_message where 1=1 ";
        sql += " and state = "+0;
        if (page >= 0 && limit > 0) {
            sql += " limit "+page+SqlSymbol.COMMA.getValue()+limit;
        }
        ResultSet resultSet = jdbcMysql.jdbcQuery(sql);
        return resultSet;
    }

    @Override
    public ResultSet count(Integer page, Integer limit) {
        sql = "select count(1) from company_message where 1=1 ";
        if (page >= 0 && limit > 0) {
            sql += " limit "+page+SqlSymbol.COMMA.getValue()+limit;
        }
        ResultSet resultSet = jdbcMysql.jdbcQuery(sql);
        return resultSet;
    }

    @Override
    public ResultSet findById(Integer id) {
        sql = "select * from company_message where id = "+id;
        ResultSet resultSet = jdbcMysql.jdbcQuery(sql);
        return resultSet;
    }

    @Override
    public int save(CompanyMessage t) {
        return 0;
    }

    @Override
    public int update(CompanyMessage t) {
        return 0;
    }

    @Override
    public int delete(Integer id) {
        return 0;
    }
}
